package com.situ.mall.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.mall.mapper.OrderItemMapper;
import com.situ.mall.pojo.entity.OrderItem;
import com.situ.mall.pojo.query.OrderItemQuery;
import com.situ.mall.pojo.vo.OrderItemVO;
import com.situ.mall.service.IOrderItemSevice;
import com.situ.mall.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderItemServiceImpl implements IOrderItemSevice {
    @Autowired
    private OrderItemMapper orderItemMapper;

    @Override
    public PageResult list(OrderItemQuery orderItemQuery) {
        PageHelper.startPage(orderItemQuery.getPage(), orderItemQuery.getLimit());
        List<OrderItemVO> list = orderItemMapper.list(orderItemQuery);
        PageInfo pageInfo = new PageInfo(list);
        int totalCount = (int) pageInfo.getTotal();
        return PageResult.ok(totalCount, list);
    }
}
